package com.sc.nft.entity.vo;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sc.nft.enums.UserMerchantPledgeTaskStatusEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.Date;

@Data
public class MerchantPledgeDataExportPreviewVO {

    @ApiModelProperty(value = "DAO名称")
    private String daoName;

    @ApiModelProperty(value = "状态 NOT_YET_STARTED:未开始,IN_PLEDGE:质押中,COMPLETED:已完成,ALREADY_ENDED:已结束 ")
    private UserMerchantPledgeTaskStatusEnum status;

    @ApiModelProperty(value = "结束时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date endTime;

    @ApiModelProperty(value = "活动名称")
    private String pledgeName;

    @ApiModelProperty(value = "活动封面")
    private String nickName;

    @ApiModelProperty(value = "手机号")
    private String userTel;


    @ApiModelProperty(value = "时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "剩余天数")
    private Integer remainingDays;

    @ApiModelProperty(value = "质押份数")
    private Integer pledgeCount;

    @ApiModelProperty(value = "剩余天数")
    private String recommendNickName;

    @ApiModelProperty(value = "推荐人昵称")
    private String recommendUserTel;

    @ApiModelProperty(value = "质押藏品")
    private String pledgeCollection;

    @ApiModelProperty(value = "奖励")
    private String rewardsDetails;

    @ApiModelProperty(value = "奖励次数")
    private String rewardsCount;

    public void setRemainingDays(Date endTime) {
        if(ObjectUtil.isNull(endTime)){
            this.remainingDays = 0;
            return;
        }

        if(status == UserMerchantPledgeTaskStatusEnum.ALREADY_ENDED || status == UserMerchantPledgeTaskStatusEnum.COMPLETED ){
            this.remainingDays = 0;
            return;
        }

        Long between = DateUtil.betweenDay(DateTime.now(),endTime, Boolean.FALSE);
        this.remainingDays = between.intValue() <=0 ? 0: between.intValue();
    }



}
